import Vue from 'vue'
import App from './App'
import store from './store'
import Axios from './common/http.js'
// Vue.prototype.$url = 'http://puyunwl.nat300.top'

Vue.config.productionTip = false
Vue.prototype.$store = store
Vue.prototype.$http = Axios;

Vue.prototype.$Host = `https://lsb.cs.djszkj.com`;


//全局组件
// import banner from "./components/banner/banner.vue"
// import lunbo from "./components/lunbo/lunbo.vue"
import zhengce from "./components/zhengce/zhengce.vue"
import hengxian from "./components/hengxian/hengxian.vue"
/* 右箭头 */
import uniIcons from '@/components/uni-icons/uni-icons.vue'
/* 地图 */
import ditu from "./components/ditu/ditu.vue"
// tree 
import tree from "./components/tree/tree.vue"
 Vue.component('hengxian',hengxian)
 Vue.component('ditu',ditu)
 Vue.component('uniIcons',uniIcons)
 // Vue.component('ditu',ditu)
// Vue.component('banner',banner)
// Vue.component('lunbo',lunbo)
Vue.component('zhengce',zhengce)
Vue.component('tree', tree)

Vue.prototype.toast = function(msg){
	uni.hideLoading();
	uni.showLoading({
		title: msg,
		icon:'none'
	});
	setTimeout(function () {
		uni.hideLoading();
	}, 1500);
}

Vue.prototype.pyReq = function(url,data,suc) {
	var that = this;
	var isShow = true;
	// uni.setStorageSync('token','89b055fb39a64a0e84e02c1c29c47e81');
	
	setTimeout(function(){
		if(isShow){
			uni.showLoading({
				title: '加载中'
			});
		}
	},1000)
	let urlFull = '';
	let baseUrl = 'http://'+uni.getStorageSync('baseUrl');
	if(url.indexOf('http')!=-1){
		urlFull = url;
	}else{
		urlFull = baseUrl+url;
	}
	
	uni.request({
		url: urlFull,
		method: "POST",
		header: {
			'Content-Type': "application/x-www-form-urlencoded",
			'token':uni.getStorageSync('token')
		},
		data: data,
		success: function(msg){
			// console.log(msg);
			setTimeout(function(){
				uni.hideLoading()
			},1500)
			isShow = false;
			
			if(msg.data.code!=0){//请求失败
				uni.hideLoading();
				uni.showLoading({
					title: msg.data.msg,
					icon:'none'
				});
				setTimeout(function () {
				    uni.hideLoading();
					//未登录需要跳转到登录页面
					if(msg.data.code == 1001){
						uni.clearStorageSync();
						uni.navigateTo({
							url:"/pages/index/logo/logo",
						})
					}
				}, 1500);
				return;
			}else if(msg.data.msg){
				if(url.indexOf('/ds1/user/signin')==-1){
					uni.hideLoading();
					uni.showLoading({
						title: msg.data.msg,
						icon:'none'
					});
					setTimeout(function () {
						uni.hideLoading();
					}, 1500);
					setTimeout(function(){
						suc(msg.data);
					},1500);
					return;
				}
			}
			suc(msg.data);
		},
		  fail: function() {
			  uni.hideLoading();
			   uni.showLoading({
				title: "网络不给力",
				icon: 'none'
			   });
			   setTimeout(function () {
			       uni.hideLoading();
			   }, 1500);
		  }
	 })
}


App.mpType = 'app'

const app = new Vue({
	store,
    ...App
})
app.$mount()
